<template>
    <div>
        <div class="product">
            <h2>销售订单编辑</h2>
            <el-form ref="form" :inline="true" :model="form" class="demo-form-inline" label-width="230px"
                style="margin:auto;width:80%;" :rules="rulesOut">
                <el-form-item label="客户" prop="partnerId" class="ww">
                    <el-select v-model="form.partnerId" filterable placeholder="请选择客户" :filter-method="customerfilterMethod"
                        style="width: 300px;">
                        <el-option v-for="item in customerdata" :key="item.id" :label="item.name"
                            :value="parseInt(item.id)">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="交货日期" prop="validityDate" class="ww">
                    <el-date-picker clearable v-model="form.validityDate" type="date" value-format="yyyy-MM-dd"
                        placeholder="请选择交货日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="合同签订日期" prop="contractDate" class="ww">
                    <el-date-picker clearable v-model="form.contractDate" type="date" value-format="yyyy-MM-dd"
                        placeholder="请选择合同签订日期">
                    </el-date-picker>
                </el-form-item>
                <!-- <el-form-item label="付款条件">
                    <el-input v-model="form.validityDate" placeholder="审批人"></el-input>
                </el-form-item> -->
                <el-form-item label="提供增值发票" prop="isProvideInvoice" class="ww">
                    <el-radio v-model="form.isProvideInvoice" label="t">提供发票</el-radio>
                    <el-radio v-model="form.isProvideInvoice" label="f">不提供发票</el-radio>
                </el-form-item>
                <el-form-item label="含税" prop="isTax" class="ww">
                    <el-radio v-model="form.isTax" label="t" @input="isfp">含税</el-radio>
                    <el-radio v-model="form.isTax" label="f" @input="isfp">不含税</el-radio>
                </el-form-item>
                <el-form-item label="承担运费" prop="isProvideFreight" class="ww">
                    <el-radio v-model="form.isProvideFreight" label="t">承担运费</el-radio>
                    <el-radio v-model="form.isProvideFreight" label="f">不承担运费</el-radio>
                </el-form-item>
                <el-form-item label="交货条件" prop="deliveryConditionsId" class="ww">
                    <el-select v-model="form.deliveryConditionsId" filterable placeholder="请选择交货条件" style="width: 300px;">
                        <el-option v-for="item in deliverydata" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="运输方式" prop="transportType" class="ww">
                    <el-radio v-model="form.transportType" label="logistics">物流公司</el-radio>
                    <el-radio v-model="form.transportType" label="courier">快递公司</el-radio>
                </el-form-item>
                <el-form-item label="备注" class="ww">
                    <el-input type="textarea" autosize v-model="form.note" placeholder="请输入备注"
                        style="width: 300px;"></el-input>
                </el-form-item>
            </el-form>
            <!-- 订单行表格 -->
            <div class="tab">
                <div class="btn">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="addorder"
                        :disabled="flag">新增订单行</el-button>
                </div>
                <el-form :model="tableForm" ref="tableForm">
                    <el-table :data="tableForm.tableData" :row-class-name="rowSysGoodsIndex"
                        style="width: 90%; margin: 5px auto 30px;" :header-cell-style="{ 'text-align': 'center' }"
                        :cell-style="{ 'text-align': 'center' }">
                        <el-table-column prop="sequence" label="序号" width="50">
                        </el-table-column>
                        <el-table-column prop="productTemplateId" label="产品名称" width="300" :render-header="thRequest">
                            <template slot-scope="scope">
                                <el-form-item :prop="'tableData.' + scope.$index + '.productTemplateId'"
                                    :rules="rules.productTemplateId">
                                    <el-select clear v-model="scope.row.productTemplateId" filterable placeholder="请选择产品"
                                        :filter-method="stockfilterMethod" @change="(val) => stockidFun(val, scope.$index)"
                                        class="thRed" style="width: 250px;">
                                        <el-option v-for="item in stockdata" :key="item.id" :label="item.name"
                                            :value="item.id">
                                        </el-option>
                                        <el-option style="color: blue;" label="搜索更多..." value="more"></el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="partMessage" label="说明" width="300">
                            <template slot-scope="scope">
                                <el-input type="textarea" autosize class="borderNone" v-model="scope.row.partMessage" />
                            </template>
                        </el-table-column>
                        <el-table-column prop="stockNum" label="库存量" width="120">
                            <template slot-scope="scope">
                                <el-input class="borderNone" v-model="scope.row.stockNum" :disabled="true" />
                            </template>
                        </el-table-column>
                        <!-- <el-table-column prop="productUom" label="单位">
                    </el-table-column> -->
                        <el-table-column prop="surfaceTreatment" label="表面处理">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.surfaceTreatment" class="borderNone">
                                    <el-option v-for="dict in dict.type.surfacetreatment_type" :key="dict.value"
                                        :label="dict.label" :value="dict.value"></el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                        <el-table-column prop="productUomQty" label="订购数量" width="100" :render-header="thRequest">
                            <template slot-scope="scope">
                                <el-form-item :prop="'tableData.' + scope.$index + '.productUomQty'"
                                    :rules="rules.productUomQty">
                                    <el-input class="thRed" v-model="scope.row.productUomQty" />
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="priceUnit" label="单价" width="100" :render-header="thRequest">
                            <template slot-scope="scope">
                                <el-form-item :prop="'tableData.' + scope.$index + '.priceUnit'" :rules="rules.priceUnit">
                                    <el-input class="thRed" v-model="scope.row.priceUnit"></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="worldchampCurrency" label="币种" width="100">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.worldchampCurrency" filterable class="borderNone">
                                    <el-option v-for="item in options" :key="item.id" :label="item.label" :value="item.id">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                        <el-table-column prop="priceSubtotal" label="总价" width="100">
                            <template slot-scope="scope">
                                <el-input class="borderNone" v-model="scope.row.priceSubtotal" :disabled="true" />
                            </template>
                        </el-table-column>
                        <!-- <el-table-column prop="productMaxQty" label="税">
                    </el-table-column> -->

                        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                            <template slot-scope="scope">
                                <!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="orderUpdate(scope.row)"
                                v-hasPermi="['system:stock:edit']">修改</el-button> -->
                                <el-button size="mini" type="text" icon="el-icon-success"
                                    @click="ordersub(scope.row)">确认</el-button>
                                <el-button size="mini" type="text" icon="el-icon-delete"
                                    @click="orderDel(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-form>
                <!-- 右下角总计 -->
                <div class="total">
                    <div class="totalright">
                        <p>总计：<strong>￥{{ amountTotal }}</strong></p>
                        <p>金额大写：<strong>{{ amountTotalDaxie }}</strong></p>
                    </div>
                </div>
            </div>
            <!-- 整体提交按钮 -->
            <div class="sub">
                <el-button type="primary" @click="submit" style="width:150px">提交</el-button>
            </div>
        </div>
        <!-- 产品搜索弹框 -->
        <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
            <hr>
            名称：<el-input style="width:150px;margin: 10px 10px" :clearable="true" placeholder="请输入内容" v-model="input2"
                @change="searchcp"></el-input>

            <!-- 型号：<el-input style="width:150px;margin: 30px 10px" :clearable="true" placeholder="请输入内容" v-model="input3"
                @change="searchcp"></el-input> -->

            <el-button type="primary" icon="el-icon-search" @click="searchcp">搜索</el-button>
            <el-table :data="stockListArr" @row-click="selecp">
                <el-table-column label="名称" align="center" prop="name" />
                <el-table-column label="规格" align="center" prop="specification" />

                <!-- <el-table-column label="内部类别" align="center" prop="categId">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.product_category" :value="scope.row.categId" />
                </template>
            </el-table-column> -->

            </el-table>
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getList" />
        </el-dialog>
    </div>
</template>
<script>
import { listPartner, getPartner } from '@/api/system/partner.js'
import { addorderzz, addquotation, quotationsub, delorderzz1, editorderzz1, editorderzzsub, getOrder, updateOrder } from '@/api/system/order.js';
import { listStock, getStock } from '@/api/system/stock.js'
import saleorder from "@/views/system/saleorder/index";
import saleorderdetail from "@/views/system/saleorderdetail/index";


export default {
    dicts: ['surfacetreatment_type'],
    data() {
        return {
            // 表格行下标
            tableindex: '',
            // 总条数
            total: 0,
            // 弹框产品的搜索
            input2: '',
            // 弹框的数组
            stockListArr: [],
            // 查询产品参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                name: null,
                sequence: null,
                description: null,
                descriptionPurchase: null,
                descriptionSale: null,
                type: null,
                categId: null,
                listPrice: null,
                volume: null,
                weight: null,
                saleOk: null,
                purchaseOk: null,
                uomId: null,
                active: null,
                color: null,
                createUid: null,
                createDate: null,
                writeUid: null,
                writeDate: null,
                specification: null,
                canBeExpensed: null,
                warehouse: null
            },
            //产品搜索弹框
            open: false,
            // 新增订单行按钮禁用
            flag: false,
            // 交货条件
            deliverydata: [
                {
                    id: 1,
                    name: '款到发货'
                },
                {
                    id: 2,
                    name: '收到30%定金后安排生产，发货前付清尾款'
                },
                {
                    id: 3,
                    name: '无需定金，发货前付全款'
                },
                {
                    id: 4,
                    name: '定作方合同盖章回传后，加工方开始安排生产，发货前付清全款'
                },
                {
                    id: 5,
                    name: '收到100%全款后安排生产'
                },
                {
                    id: 6,
                    name: '合同盖章后开始排产。先发货，后付款'
                },

            ],
            // 币种
            options: [{
                id: 3,
                label: 'USD'
            }, {
                id: 22,
                label: 'AUD'
            }, {
                id: 8,
                label: 'CNY'
            }],

            // 修改订单行表单参数
            form2: {},
            // 修改订单行弹框
            orderzzedit: false,
            // 总价
            amountTotal: 0,
            // 大写
            amountTotalDaxie: '零',
            // 用来存储赋值给tabledata
            saleOrderParts: [],
            // 外层客户名称表单验证
            rulesOut: {
                partnerId: [
                    { required: true, message: "客户不能为空", trigger: ["blur", 'change'] }
                ],
                validityDate: [
                    { required: true, message: "交货日期不能为空", trigger: "blur" }
                ],
                contractDate: [
                    { required: true, message: "合同签订日期不能为空", trigger: "blur" }
                ],

                isProvideInvoice: [
                    { required: true, message: "是否提供增值税发票不能为空", trigger: "blur" }
                ],
                isTax: [
                    { required: true, message: "是否含税不能为空", trigger: "blur" }
                ],
                isProvideFreight: [
                    { required: true, message: "是否承担运费不能为空", trigger: "blur" }
                ],
                deliveryConditionsId: [
                    { required: true, message: "交货条件不能为空", trigger: "blur" }
                ],
                // 运输方式
                transportType: [
                    { required: true, message: "运输方式不能为空", trigger: "blur" }
                ],
            },
            // 订单行校验
            rules: {
                priceUnit: [
                    { required: true, message: "单价不能为空", trigger: ["blur"] },
                    { pattern: /^(([0-9][0-9]*)|(([0]\.\d{1,2}|[0-9][0-9]*\.\d+$)))$/, message: "只能输入正整数或小数", trigger: "blur" }
                ],
                productTemplateId: [
                    { required: true, message: "产品不能为空", trigger: ["blur", 'change'] }
                ],
                productUomQty: [
                    { required: true, message: "必须为数字值", trigger: ["blur"] },
                    { pattern: /^[+]{0,1}(\d+)$/, message: '必须为数字值', trigger: ["blur"] }

                ],
            },
            title: '',
            // 订单行弹框
            orderzz: false,
            // 产品数组
            stockdata: [],
            // 外层表单参数
            form: {},
            // 新增订单行表单参数
            form1: {
                priceUnit: null,
                surfaceTreatment: null,
                isPrint: null,
                worldchampCurrency: null,
                invoiceStatus: null,
                partMessage: null,
                productUomQty: null,
                // productId:null

            },
            tableForm: {
                // priceUnit:null,
                tableData: [{ priceUnit: null, }]
            },
            /// 查询客户参数,用于下拉框
            queryParamsCustom: {
                pageNum: 1,
                pageSize: 10,
                customer: 't',
            },
            // 客户下拉框
            customerdata: [],
        };
    },
    mounted() {
        let query = this.fid || this.$route.query.listId;
        this.getSaleOrderWrite(query)
        this.stockList()
        this.customerList()

    },
    methods: {
        // 点击修改销售订单跳转后请求
        getSaleOrderWrite(query) {
            // console.log(query);
            getOrder(query).then(res => {
                // console.log(res);
                this.form = res.data
                // console.log(this.form.partnerId);
                // 把返回的客户id查询详情并添加到客户选择框中回显
                getPartner(this.form.partnerId).then(resp => {
                    // console.log(resp);
                    // const obj = res.data
                    const flag1 = this.customerdata.some((item, index) => {
                        if (item.id === this.form.partnerId) {
                            return true
                        }
                    })
                    // console.log(flag1);
                    if (!flag1) {
                        this.customerdata.push(resp.data)
                    }

                    // console.log(this.options);
                })
                this.tableForm.tableData = res.data.saleOrderParts
                const aa = (this.tableForm.tableData.map(item => {
                    // 把返回的产品id查询详情并添加到产品选择框中回显
                    getStock(item.productTemplateId).then(res => {
                        // console.log(res);

                        const obj = res.data
                        const flag2 = this.stockdata.some((item2, index) => {
                            if (item2.id === item.productTemplateId) {
                                return true
                            }
                        })
                        // console.log(flag2);
                        if (!flag2) {
                            this.stockdata.push(obj)
                        }

                    })
                }))
                this.amountTotalDaxie = res.data.amountTotalDaxie
                this.amountTotal = res.data.amountTotal
                // console.log(this.form);
                // console.log(this.tableForm.tableData);
                // this.form.isProvideInvoice = res.data.isProvideInvoice
                // this.form.isTax = res.data.isTax
                // this.form.isProvideFreight = res.data.isProvideFreight
                // this.form.transportType = res.data.transportType

            })
        },
        // 在弹框选中产品回写到产品行
        selecp(row) {
            // console.log(row.id);
            // console.log(this.tableindex);
            this.tableForm.tableData[this.tableindex].productTemplateId = row.id
            this.open = false
            this.stockidFun(row.id)
        },
        /** 查询库存列表 */
        getList() {
            // this.loading = true;
            this.queryParams.params = {};
            if (null != this.daterangeCreateDate && '' != this.daterangeCreateDate) {
                this.queryParams.params["beginCreateDate"] = this.daterangeCreateDate[0];
                this.queryParams.params["endCreateDate"] = this.daterangeCreateDate[1];
            }
            if (null != this.daterangeWriteDate && '' != this.daterangeWriteDate) {
                this.queryParams.params["beginWriteDate"] = this.daterangeWriteDate[0];
                this.queryParams.params["endWriteDate"] = this.daterangeWriteDate[1];
            }
            listStock(this.queryParams).then(response => {
                this.stockListArr = response.rows;
                this.total = response.total;
                this.stockdata = response.rows
                this.loading = false;
            });
        },
        // 表格表头行显示必填*
        thRequest(h, colunm) {
            // console.log(h);
            // console.log(colunm);
            // console.log(colunm.column.label);
            return [
                h('span', { style: 'color:#f56c6c' }, '*'),
                h('span', ' ' + colunm.column.label)
            ]

        },
        // 点击新增订单行触发
        addorder() {
            this.flag = true
            // this.orderzz = true
            // this.reset()
            let obj = {};
            obj.name = "";
            obj.surfaceTreatment = "";
            obj.productUomQty = "";
            obj.priceUnit = "";
            obj.worldchampCurrency = "";
            obj.partMessage = "";
            // console.log(this.tableForm.tableData);
            if (this.tableForm.tableData === null) {
                this.tableForm.tableData = []
            }
            this.tableForm.tableData.push(obj);
        },
        // 订单行确认按钮
        ordersub(row) {
            // console.log(this.tableForm);
            this.$refs["tableForm"].validate((valid) => {
                // console.log(valid);
                if (valid) {
                    this.flag = false
                    const id = row.sequence - 1
                    // console.log(id);
                    // console.log(this.tableForm.tableData);
                    // const arr = []
                    // arr.push(this.tableForm.tableData[id])
                    this.form.saleOrderParts = this.tableForm.tableData
                    // console.log(this.form);
                    addquotation(this.form).then(res => {
                        // console.log(res);
                        this.form = res.data
                        this.tableForm.tableData = res.data.saleOrderParts
                        this.amountTotalDaxie = res.data.amountTotalDaxie
                        this.amountTotal = res.data.amountTotal

                    })
                }
            })
        },
        // 点击删除订单行触发
        orderDel(row) {
            const that = this
            // console.log(row);
            const id = row.sequence
            // this.delorder(id)
            this.$modal.confirm('是否确认删除产品名称为"' + row.name + '"的数据项？').then(function () {
                return that.delorder(id)
            }).then(() => {
                // this.getList();
                this.$modal.msgSuccess("删除成功");
            }).catch((err) => {
                // console.log(err);
            });

        },
        // 删除订单行接口方法
        delorder(id) {
            // console.log(this.flag);
            // console.log(this.flag === true);
            if (this.flag === true) {
                this.tableForm.tableData.pop()
                this.flag = false

            } else {
                // console.log(this.tableForm.tableData);
                delorderzz1(id).then(res => {
                    // console.log(res);
                    // console.log(this.saleOrderParts);
                    // this.saleOrderParts = res.data.saleOrderParts
                    this.form = res.data
                    // console.log(this.form);

                    this.tableForm.tableData = res.data.saleOrderParts
                    this.amountTotalDaxie = res.data.amountTotalDaxie
                    this.amountTotal = res.data.amountTotal
                })
            }
        },
        /** 序号 */
        rowSysGoodsIndex({ row, rowIndex }) {
            row.sequence = rowIndex + 1;
        },

        // 修改报价单提交
        submit() {
            const that = this
            this.$refs["form"].validate((valid) => {
                if (valid) {
                    //   alert('submit!');
                    // console.log(this.form);
                    const aa = this.form
                    // quotationsub(this.form).then(res => {
                    //     console.log(res);
                    // })
                    this.$modal.confirm('是否确认提交修改的报价单').then(function () {
                        return updateOrder(aa).then({})
                    }).then(() => {
                        // this.getList();
                        // this.getStkBomPart(stockid)
                        this.$modal.msgSuccess("修改成功");
                        that.setOpenEditSale()
                        // console.log(that.$route.query.listId);
                        // console.log(this.$route.query.listId);

                        // this.$router.push({
                        //     path: "/saleorderdetail",
                        //     query: {listId:this.$route.query.listId},
                        //     component: saleorderdetail,
                        //     redirect: "noRedirect",
                        //     hidden: false,
                        //     alwaysShow: true,
                        // });
                    }).catch((err) => {
                        // console.log(err);
                        this.$message("修改失败");
                    });
                } else {
                    // console.log('error submit!!');
                    return false;
                }
            });

        },
        // 发送给父组件销售订单详情
        setOpenEditSale() {
            // console.log('触发了' + this.$route.query.listId);
            this.$emit('transfer', false, this.$route.query.listId)//触发transfer方法，this.user 为向父组件传递的数据
        },
        // 是否提供发票根据是否含税
        isfp(e) {
            // console.log(e);
            if (e == 't') {
                this.form.isProvideInvoice = 't'
            }
            else {
                this.form.isProvideInvoice = 'f'
            }
        },
        // 产品弹框的搜索
        searchcp() {
            const que = {
                pageNum: 1,
                pageSize: 10,
                name: this.input2,
                // stockType: this.input3

            }
            listStock(que).then(response => {
                // console.log(response);
                this.stockListArr = response.rows;
                this.total = response.total;

                // this.loading = false;
            });
        },


        //    表格行产品赋值
        stockidFun(e, index) {
            // console.log(e);
            // console.log(index);
            if (e == 'more') {
                // console.log('123');
                this.open = true
                this.title = '搜索：产品'
                this.tableForm.tableData[index].productTemplateId = ''
                this.tableindex = index
                this.getList()
            } else {
                // console.log(e);
                addorderzz(e).then(res => {
                    // console.log(res);
                    // console.log(this.tableForm.tableData);
                    // console.log(this.tableForm.tableData.length - 1);
                    const arr = this.tableForm.tableData.map(item => {
                        if (item.sequence === this.tableForm.tableData.length) {
                            item.priceUnit = res.data[0].priceUnit
                            item.invoiceStatus = res.data[0].invoiceStatus
                            item.productUomQty = res.data[0].productUomQty
                            item.surfaceTreatment = res.data[0].surfaceTreatment
                            item.productUom = res.data[0].productUom
                            item.worldchampCurrency = res.data[0].worldchampCurrency
                            item.partMessage = res.data[0].partMessage
                            item.name = res.data[0].name
                            item.productId = res.data[0].productId
                        }
                    })
                })
            }
        },

        // 下拉框选择产品组件,用于下拉框显示默认十条
        stockList() {
            listStock(this.stockquery).then(res => {
                // console.log(res);
                this.stockdata = res.rows
                // console.log(this.stockdata);

            })
        },
        // 产品搜索，用于直接在下拉框搜索
        stockfilterMethod(node, val) {
            // console.log(node, val);
            const que = {
                name: node,
                pageSize: 100
            }
            // console.log(que);
            listStock(que).then(res => {
                // console.log(res);
                this.stockdata = res.rows
            })
        },

        // 清空订单行
        reset() {
            this.form1 = {
                invoiceStatus: null,
                productUomQty: null,
                priceUnit: null,
                surfaceTreatment: null,
                worldchampCurrency: null,
                partMessage: null,
                isPrint: null,
                name: null,
                // productId:null

            }
        },
        // 下拉框选择客户
        customerList() {
            listPartner(this.queryParamsCustom).then(res => {
                // console.log(res);
                this.customerdata = res.rows

                // console.log(typeof (res.rows[0].id));
                // console.log(this.customerdata);

            })
        },
        // 客户搜索
        customerfilterMethod(node, val) {

            // console.log('val', val, 'node', node)
            // console.log(node);
            const que = {
                name: node,
                pageSize: 100,
                customer: 't'
            }
            // console.log(que);
            listPartner(que).then(res => {
                // console.log(res);
                this.customerdata = res.rows
            })
        },
        // 取消按钮
        cancel() {
            this.orderzz = false;
            this.orderzzedit = false;
            // this.Bomadd = false;
            //   this.reset();
        },
        // 订单行新增提交
        orderForm() {
            this.$refs["form1"].validate(valid => {
                if (valid) {
                    // console.log(this.saleOrderParts);
                    // console.log(this.form1);
                    // console.log(this.form);
                    if (this.saleOrderParts === null) { this.saleOrderParts = [] }
                    // this.saleOrderParts=[]
                    this.saleOrderParts.push(this.form1)
                    this.form.saleOrderParts = this.saleOrderParts
                    // console.log(this.saleOrderParts);
                    // console.log(this.form);
                    addquotation(this.form).then(res => {
                        // console.log(res);
                        this.orderzz = false
                        this.tableForm.tableData = res.data.saleOrderParts
                        this.form = res.data
                        this.amountTotalDaxie = res.data.amountTotalDaxie
                        this.amountTotal = res.data.amountTotal
                    })
                    //         //   if (this.form.id != null) {
                    //         //     updateStock(this.form).then(response => {
                    //         //       this.$modal.msgSuccess("修改成功");
                    //         //       this.open = false;
                    //         //       this.getList();
                    //         //     });
                    //         //   } else {
                    //         addBomPart(this.Bomform).then(response => {
                    //             this.$modal.msgSuccess("新增成功");
                    //             this.Bomadd = false;
                    //             //   this.getList();
                    //             this.getStkBomPart(this.Bomform.stockId)
                    //         });
                    //         //   }
                }
            });
        },
        // 点击编辑订单行触发
        orderUpdate(row) {
            const id = row.sequence
            this.orderzzedit = true
            editorderzz1(id).then(res => {
                // console.log(res);
                this.title = '修改订单行'
                this.form2 = res.data

            })
        },
        // 编辑订单行提交
        editsuborderForm() {
            // console.log(this.form2);
            editorderzzsub(this.form2).then(res => {
                // console.log(res);
                this.saleOrderParts = res.data.saleOrderParts
                this.form = res.data
                this.tableForm.tableData = res.data.saleOrderParts
                this.amountTotalDaxie = res.data.amountTotalDaxie
                this.amountTotal = res.data.amountTotal
                this.orderzzedit = false
            })
        },
    },
    components: {},
    props: {
        fid: {
            type: Number, default: null
        }
    },
    watch: {},
    computed: {},
    created() { },
};
</script>
<style lang="scss" scoped>
.ww {
    width: 600px;
    // border: 1px red solid;
}

.product {
    width: 100%;
    background: #fff;
    border: 1px rgb(232, 228, 228) solid;
    // box-shadow: 0 3px 20px -15px #000000;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    margin: 10px auto;
}

h2 {
    text-align: center;
    line-height: 60px;
}

.btn {
    margin-left: 5%;
}

.sub {
    // width: 80%;
    // border: 1px red solid;
    text-align: center;
    margin-bottom: 20px;

}

.total {

    // border: 1px red solid;
    width: 90%;
    margin: 50px auto;

    // margin: 40px 60% 30px;
    // border-top: 2px gray solid;
    // text-align:right;
    .totalright {
        width: 30%;
        // float: right;
        margin-left: 70%;
        border-top: 2px gray solid;

        p {
            line-height: 40px;
            text-align: right;
        }
    }

}

.thRed {
    // height: 200px;
    margin-top: 22px;
}

// .borderNone ::v-deep .el-input__inner {
//   border: none;

//   border-bottom: 2px black solid;
// }
</style>